//package com.plian.system.controller.sys.sun;
//
//import com.plian.Tools.CollectionUtil;
//import com.plian.Tools.TokenUtil;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.spring.SpringUtil;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.ObjResult;
//import com.plian.system.service.sys.orgzation.OrgzationService;
//import com.plian.system.service.sys.user.UserService;
//import com.plian.system.vo.sys.SunPurchaseOrgVO;
//import com.plian.system.vo.sys.SunPurchaseUserVO;
//import lombok.AllArgsConstructor;
//import org.springframework.core.env.Environment;
//import org.springframework.util.DigestUtils;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.List;
//
///**
// * @author panqb
// * @version 1.0
// * @description:阳光采购对接接口
// * @date 2022/1/28 下午5:12
// */
//@RestController
//@AllArgsConstructor
//@RequestMapping("api/sunpurchase")
//public class SunPurchaseController {
//    private OrgzationService orgzationService;
//
//    private UserService userService;
//
//    /**
//     * 返回组织节点
//     * @param lastUpdateTime
//     * @return
//     */
//    @GetMapping(value = "/getOrg")
//    public ListResult<SunPurchaseOrgVO> getOrg(String lastUpdateTime){
//        List<SunPurchaseOrgVO> sunPurchaseOrgVOS = orgzationService.findByUpdateTimeForSun(lastUpdateTime);
//        ListResult<SunPurchaseOrgVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        listResult.setList(sunPurchaseOrgVOS);
//        listResult.setTotal(CollectionUtil.isNotEmpty(sunPurchaseOrgVOS) ? sunPurchaseOrgVOS.size() : 0);
//        return listResult;
//    }
//
//    /**
//     * 根据更新时间获取用户
//     * @param lastUpdateTime
//     * @return
//     */
//    @GetMapping(value = "/getUser")
//    public ListResult<SunPurchaseUserVO> getUser(String lastUpdateTime){
//        List<SunPurchaseUserVO> sunPurchaseUserVOS = userService.findByUpdateTimeForSun(lastUpdateTime);
//        ListResult<SunPurchaseUserVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        listResult.setList(sunPurchaseUserVOS);
//        listResult.setTotal(CollectionUtil.isNotEmpty(sunPurchaseUserVOS) ? sunPurchaseUserVOS.size() : 0);
//        return listResult;
//
//    }
//
//    /**
//     * 返回阳光采购平台的登录地址
//     * @return
//     */
//    @GetMapping(value = "/getSunPurchaseLoginUrl")
//    public ObjResult getSunPurchaseLoginUrl(){
//        ObjResult objResult=new ObjResult(CommonCode.SUCCESS);
//        Environment environment = SpringUtil.getBean(Environment.class);
//        String url = environment.getProperty("sunpurchase.url");
//        String token = environment.getProperty("sunpurchase.token");
//        String appid= TokenUtil.getTokenUserId();
//        String apptype="g";
//        String appcomcode="gzw";
//        SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmm");
//        Date date=new Date();
//        String apptime=sdf.format(date);
//        String str=appid+apptype+appcomcode+apptime+token;
//        String appkey= DigestUtils.md5DigestAsHex(str.getBytes());
//        PageData pageData=new PageData();
//        url=url+"?appid="+appid+"&apptype="+apptype+"&appcomcode="+appcomcode+"&apptime="+apptime+"&appkey="+appkey;
//        pageData.put("url",url);
//        objResult.setPageData(pageData);
//        return objResult;
//    }
//
//}
